import java.util.Scanner;

public class Solution {
    public int[] twoSum(int[] price, int target){
        int len = price.length;
        int left = 0,right = len-1;
        while(left < right){
            int sum = price[left] + price[right];
            if(sum < target){
                left++;
            } else if (sum > target) {
                right--;
            }else{
                return new int[]{price[left],price[right]};
            }
        }
        return new int[]{0};
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int size = in.nextInt();
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = in.nextInt();
            }
            int target = in.nextInt();
            Solution solution = new Solution();
            int[] newArr = solution.twoSum(arr,target);
            for (int i = 0; i < newArr.length; i++) {
                System.out.print(newArr[i]+" ");
            }
        }
    }
}
